|
|
|
|
|
|
|
8. Click OK to close the Menu Editor. |
|
|
|
|
|
|
|
|
After following these steps, your form should have a menu bar like the one illustrated in Figure 6.4. |
|
|
|
|
|
|
|
|
Figure 6.4
This menu bar, shown at designtime,
was created with the Menu Editor. |
|
|
|
|
|
|
|
|
You may have expected the menu to look different than this, with the New menu being a sub-item within the File menu. Instead, both File and New are top-level menus. To fix this problem, you need to learn about the different levels that a menu can have. You learn more information about this topic in the following section, "Multiple-Level Menus." |
|
|
|
|
|
|
|
|
You may also have tried clicking one of the menu items in the design environment. If you did, you were presented with a Code window. What you've done here is the equivalent of double-clicking an object on a form at designtime: You've opened the Click event procedure associated with the menu item that you clicked. Here, you can write code to be executed when that menu item is chosen at runtime. You learn about writing code for menu items later in the chapter in the section "Writing Code for the Menu Items"; for now, just close the Code window. |
|
|
|
|
|
|
|
|
Typical menus in Windows-based applications contain multiple levels of commands. Top-level menu items are the ones that are visible in the program's menu bar. Normally, clicking a top-level menu item opens that item's submenu. Each item in a submenu can represent either a program command or another submenu. In Visual Basic, your menus can have up to six levels of submenus. |
|
|
|
|
| |
|
|
|
|
Although Visual Basic allows menus to have up to six levels, you should usually limit your program's menus to two or three levels. Too many levels can make navigating the menu system more difficult for your users. |
|
|
|
|
|
|
|
|
|
|
Follow these steps to continue creating the File menu you started in the preceding section and to add the Edit and Options menus: |
|
|
|
|
|
|
|
|
1. While Form1 is selected, open the Menu Editor. |
|
|
|
|
|
|
|
|
2. In the box at the bottom of the Menu Editor, click the New item to select it. |
|
|
|
|
|
|
|
|
3. Locate the four arrow buttons in the left-center area of the Menu Editor. Then click the right-facing arrow once. This action moves the selected menu item down a level. Notice in the box that the caption for this item becomes indented as a visual cue that it is a lower-level item. Clicking the left-facing arrow moves the item up a level. |
|
|
|
|
|